import { ajax } from '@/utils'

import type { ActData, AnswerItem } from './questionTypes'

const baseUrl = '/yswy-zy-activity'

export default {
  /** 活动列表 */
  getActivityList(data): Promise<any> {
    return ajax.post(`${baseUrl}/answer/activity/list`, data)
  },
  /** 新建活动 */
  crateActivity(data: ActData): Promise<any> {
    return ajax.post(`${baseUrl}/answer/activity/create`, data)
  },
  /** 编辑活动 */
  editActivity(data: ActData): Promise<any> {
    return ajax.post(`${baseUrl}/answer/activity/edit`, data)
  },
  /** 获取活动 */
  getActivityDetail(id: any): Promise<ActData> {
    return ajax.get(`${baseUrl}/answer/activity/detail/${id}`)
  },
  /** 结束活动 */
  finishActivity(id: any): Promise<any> {
    return ajax.get(`${baseUrl}/answer/activity/end/${id}`)
  },
  /** 发布活动 */
  publishActivity(id: any): Promise<any> {
    return ajax.get(`${baseUrl}/answer/activity/release/${id}`)
  },
  /** 删除活动 */
  deleteActivity(id: any): Promise<any> {
    return ajax.get(`${baseUrl}/answer/activity/delete/${id}`)
  },
  /** 数据汇总 */
  getSummaryData(id: any): Promise<any> {
    return ajax.get(`${baseUrl}/answer/activity/summary/data/detail/${id}`)
  },
  /** 提交情况 */
  getMemberList(data): Promise<any> {
    return ajax.post(
      `${baseUrl}/answer/activity/member/submit/detail/list`,
      data
    )
  },
  /** 答题统计 */
  getStatiicsList(activityId): Promise<any> {
    return ajax.post(`${baseUrl}/answer/activity/question/statistics/list`, {
      activityId
    })
  },
  /** 答卷详情 */
  getAnswerDetail(activityId, memberId): Promise<AnswerItem[]> {
    return ajax.post(`${baseUrl}/answer/activity/member/apply/detail`, {
      activityId,
      memberId
    })
  }
}
